package day0722;

public class test {
    public static void main(String[] args) {
        Animal2 a=new Chick();
        if (a instanceof Swim){
            Swim a2=(Swim) a;
            a2.swim();
        }else {
            Animal2 a2= a;
            a2.eat();
        }
    }
}


abstract class Animal2{
    abstract void eat();
    void drink(){
        System.out.println("喝水");
    }
}


interface Swim{
    void swim();
}


class Fish  extends Animal2  implements Swim{
    public void eat(){
        System.out.println("吃");
    }
    public void swim(){
        System.out.println("游泳");
    }
}

class Chick extends Animal2{
    public void eat(){
        System.out.println("吃");
    }
}

